﻿using System;

namespace Game1942.Library
{
    public class EnergyCounter
    {
        private int energy;
        private readonly int energyLimit;

		// Constructor
        public EnergyCounter(int anEnergyLimit)
        {
            energyLimit = energy = anEnergyLimit;
        }

		// Getters
        public int Value
        {
            get { return energy; }
            set
            {
                energy = value;
                if (energy<0)
                {
                    energy = 0;
                }
                if (energy>energyLimit)
                {
                    energy = energyLimit;
                }
            }
        }

        public int EnergyLimit
        {
            get { return energyLimit; }
        }

        public void Change (int energyAdded)
        {
            Value = energy + energyAdded;
        }
    }
}
